from django.db import models


# Create your models here.
# 菜单栏
class MenuModel(models.Model):
    pid = models.ForeignKey(to='self', on_delete=models.CASCADE, related_name='children', null=True, default=None)
    name = models.CharField(max_length=10)
    path = models.CharField(max_length=20)
    redirect = models.CharField(max_length=20, null=True)
    component = models.CharField(max_length=20)
    icon = models.CharField(max_length=20, null=True)
    key = models.CharField(max_length=20)
    keepAlive = models.BooleanField(null=True)
    hidden = models.BooleanField(null=True)

    def __str__(self):
        return self.name


#  角色列表
class RoleModel(models.Model):
    name = models.CharField(max_length=20)
    access = models.CharField(max_length=20)  # pc后台权限
    access_delete = models.IntegerField(default=0)
    access_export = models.IntegerField(default=0)
    access_mobile = models.CharField(max_length=20)  # 移动端后台权限
    access_set_service = models.IntegerField(default=0)

    # user_total 该角色的用户总数
    def __str__(self):
        return self.name


# 用户列表
class AdminModel(models.Model):
    username = models.CharField(max_length=20)
    role = models.ForeignKey(to="RoleModel", on_delete=models.CASCADE)
    password = models.CharField(max_length=100)
    last_login_ip = models.CharField(max_length=50)
    last_login_ipaddress = models.CharField(max_length=50)
    last_login_time = models.IntegerField()
    addtime = models.IntegerField()  # 添加用户时间
    avatar = models.CharField(null=True, max_length=200)
    bind_qywx = models.IntegerField(default=0)
    bind_qywx_time = models.IntegerField(default=0)
    is_sc = models.BooleanField(default=True)
    mobile = models.CharField(max_length=100, null=True)
    token = models.CharField("token值", max_length=150, default="", null=True)
    expired_at = models.IntegerField("过期时间", default=0, null=True)

    def __str__(self):
        return self.username


# 用户日志
class LoginMesModel(models.Model):
    addtime = models.IntegerField()
    admin = models.ForeignKey(to="AdminModel", on_delete=models.CASCADE)
    content = models.CharField(max_length=200)  # 登录返回信息 列：登录成功
    ip = models.CharField(max_length=50)
    ip_addr = models.CharField(max_length=100)
    is_login = models.BooleanField(default=True)  # 是否是登录的信息

# ##########################################  会员管理
#来源
class PlatfromModels(models.Model):
    name  = models.CharField(max_length=10)

    def __str__(self):
        return  self.name

# 会员数据
class MemberModels(models.Model):
    # avatar = models.IntegerField(default=0,null=True)
    companyname = models.CharField(max_length=50,null=True) #公司名称/个人名称
    disable_im = models.IntegerField(default=0,null=True)  #是否禁聊
    email = models.CharField(max_length=50,null=True) #邮箱
    is_openid = models.CharField(max_length=50,null=True) #是否绑定微信
    last_login_address = models.CharField(max_length=50,null=True)#最后登录地址
    last_login_ip = models.CharField(max_length=50,null=True)#最后登录ip
    last_login_time = models.IntegerField(default=0,null=True) #最后登录时间
    mobile = models.CharField(max_length=50) #手机号
    openid = models.CharField(max_length=50,null=True) #微信号
    platform = models.ForeignKey(to="PlatfromModels",on_delete=models.CASCADE) #注册来源
    reg_address = models.CharField(max_length=50,null=True) #注册地址
    reg_ip = models.CharField(max_length=50,null=True) # 注册ip
    reg_time = models.CharField(max_length=50) #注册时间
    # robot = models.IntegerField()
    status = models.IntegerField(default=1,null=True) # 会员状态
    username = models.CharField(max_length=50) #会员名称
    utype = models.IntegerField() #会员类型
    password  = models.CharField(max_length=20,null=True) #会员密码


###################### 简历管理
class Citycategory(models.Model):
    pid = models.ForeignKey(to='self', on_delete=models.CASCADE, related_name='children', null=True, default=None)
    value = models.IntegerField() # 地区编码
    label =  models.CharField(max_length=10)#地区名称
    level = models.IntegerField(null=True)  # 等级
    hasChildren = models.BooleanField(default=True)  # 是否又子级
    sort_id = models.IntegerField(default=0)
    spell = models.CharField(max_length=20,null=True)  # 拼音
    alias = models.CharField(max_length=30,null=True)  # 别名
    def __str__(self):
        return self.label


# 学历
class Eduction(models.Model):
    name = models.CharField(max_length=10)#学历
    def __str__(self):
        return  self.name

# 工作种类
class Jobcategory(models.Model):
    pid = models.ForeignKey(to='self', on_delete=models.CASCADE, related_name='children', null=True, default=None)
    value = models.IntegerField()  # 工作编码
    label = models.CharField(max_length=10)  # 工作名称
    level = models.IntegerField(default=0) #等级
    hasChildren = models.BooleanField(default= True) #是否又子级
    sort_id = models.IntegerField(default=0)
    spell = models.CharField(max_length=20,null=True) # 拼音
    content = models.CharField(max_length=30,null=True) #内容
    def __str__(self):
        return self.label



# 专业种类
class Jobmajors(models.Model):
    pid = models.ForeignKey(to='self', on_delete=models.CASCADE, related_name='children', null=True, default=None)
    # value = models.IntegerField()  # 工作编码
    label = models.CharField(max_length=10)  # 工作名称
    level = models.IntegerField() #等级
    hasChildren = models.BooleanField() #是否又子级
    sort_id = models.IntegerField(default=0)
    # spell = models.CharField(max_length=20) # 拼音
    def __str__(self):
        return self.label




#是否通过状态
class ResumeAudit(models.Model):
    name = models.CharField(max_length=10)#状态
    def __str__(self):
        return  self.name
# 职位信息
# 招聘信息 状态
class JobDisplay(models.Model):
    name = models.CharField(max_length=10)# 招聘状态 / 招聘中 已暂停
    def __str__(self):
        return  self.name
# 公司福利
class JobTag(models.Model):
    name =  models.CharField(max_length=10) #公司福利内容
    def __str__(self):
        return  self.name
# 职位性质
class JobNature(models.Model):
    name =  models.CharField(max_length=10)
    def __str__(self):
        return  self.name
# 工作经验
class Experience(models.Model):
    name =  models.CharField(max_length=10)
    def __str__(self):
        return  self.name
# 公司信息表
class Company(models.Model):
    name = models.CharField(max_length= 20)

    def __str__(self):
        return  self.name

#联系方式
class Contact(models.Model):
    mobile  = models.CharField(max_length=20)
    weixin = models.CharField(max_length=20)
    telephone = models.CharField(max_length=20)
    qq = models.CharField(max_length=20)
    email = models.CharField(max_length=20)

    def __str__(self):
        return self.mobile
    # def __str__(self):
    #     phone = {
    #         "mobile":self.mobile ,
    #         'telephone':self.telephone
    #     }
    #     return phone

# 职位信息
class PositionInfo(models.Model):
    address  = models.CharField(max_length=50,null=True)#工作地址
    addtime  = models.IntegerField() #添加时间
    amount = models.IntegerField()# 招聘数量 0表示若干
    audit = models.ForeignKey(to="ResumeAudit",on_delete=models.CASCADE) #审核状态
    company= models.ForeignKey(to="Company" , on_delete= models.CASCADE) #公司
    contact = models.ForeignKey(to='Contact',on_delete=models.CASCADE)  #联系方式
    content  = models.CharField(max_length=50,null=True) # 职位描述
    department = models.CharField(max_length=10,null=True) #部门
    education = models.ForeignKey(to='Eduction',on_delete=models.CASCADE) #学历要求
    emergency = models.IntegerField(null=True) #紧急程度
    experience = models.ForeignKey(to='Experience',on_delete=models.CASCADE) #工作经验
    is_display = models.BooleanField(null=True)#是否显示
    job_link = models.CharField(max_length=200) # 链接地址
    jobname = models.CharField(max_length=10,null=True) #职位名称
    map_lat = models.CharField(max_length=20,null=True) #维度
    map_lon = models.CharField(max_length=20,null=True) #经度
    map_zoom = models.IntegerField(default=15,null=True) #地图方法倍数
    maxage = models.IntegerField(null=True)  #最大年龄
    maxwage = models.IntegerField(null=True) #最大薪资
    minage = models.IntegerField(null=True) #最小年龄
    minwage =models.IntegerField(null=True) #最大薪资
    negotiable = models.BooleanField(null=True) #是否可转让
    platform = models.ForeignKey(to="PlatfromModels",on_delete=models.CASCADE) #注册来源
    refreshtime  = models.IntegerField(null=True) #刷新时间
    sex = models.BooleanField(null=True) #性别
    sitename =  models.CharField(max_length=20,null=True)#网站名称
    tag  = models.CharField(max_length=200,null=True) #  公司福利待遇
    job_display  = models.ForeignKey(to='JobDisplay',on_delete=models.CASCADE) #招聘信息状态
    img = models.CharField(max_length=300,null=True)






# # 简历用户详情
# class Resumedetails(models.Model):
#     sex = models.IntegerField()#0女 1男
#
#
#
# #简历 3
# class Resume(models.Model):
#     uid = models.ForeignKey(to='Resumedetails',on_delete=models.CASCADE)#用户序列号
#     audit = models.ForeignKey(to='ResumeAudit',on_delete=models.CASCADE) #审核状态
#     comment = models.CharField(max_length=500) #评论
#     complete_percent = models.IntegerField() #资料完成百分比
#     contact_mobile  = models.CharField(max_length=20) # 联系手机
#     delivery_num = models.IntegerField() #投递数
#     downloaded = models.IntegerField() #下载量
#     education =  models.ForeignKey(to='Eduction',on_delete=models.CASCADE) # 学历
#     enter_job_time = models.IntegerField()# 参加工作时间
#     experience_cn = models.CharField(max_length=10)#'参加工作年数'
#     final_follow = models.CharField(max_length=100)#"刷新时间"
#     follow_num = models.IntegerField()#关注数
#     fullname = models.CharField(max_length=10) #全部名称
#     high_quality = models.IntegerField() #等级
#     invitation = models.IntegerField()#被面邀数
#     is_bind = models.BooleanField ()#是否绑定
#     is_display = models.BooleanField()#是否显示
#     is_status_phone  = models.BooleanField()#联系状态 （phone）
#     is_status_weixin = models.BooleanField()#联系状态 （WX）
#     last_login_time = models.IntegerField()#最后登录时间
#     last_visit_time= models.IntegerField()#最后访问时间
#     link = models.CharField(max_length=1000) #详情链接
#     member_mobile = models.IntegerField()# 会员手机号
#     # photo_img:0
#     photo_img_src =  models.CharField() #照片地址
#     refreshtime= models.IntegerField()#更新时间
#     reg_time = models.IntegerField()#注册时间
#     remark = models.CharField(max_length=200)#备注
#     viewed = models.IntegerField()#被查看数
#     platfrom  = models.ForeignKey(to='PlatfromModels',on_delete=models.CASCADE)# 数据来源
#
#

# #####广告位type
# class Regin_from(models.Model):
#    name =  models.CharField(max_length=10)
#    def __str__(self):
#        return self.name

class Regin_type(models.Model):
    name = models.CharField(max_length=10)
    def __str__(self):
        return self.name

##广告位
class Regin_gg(models.Model):
    title = models.CharField(max_length=20)
    num = models.IntegerField()
    region = models.ForeignKey(to="PlatfromModels",on_delete=models.CASCADE)
    height = models.CharField(max_length=10)
    width = models.CharField(max_length=10)
    use_name = models.CharField(max_length=30)
    type = models.ForeignKey(to="Regin_type",on_delete=models.CASCADE)
    def __str__(self):
        return self.title


# ###广告列表
class ADlist(models.Model):
    is_display =  models.IntegerField()
    cid = models.IntegerField()
    title= models.CharField(max_length=20)
    imageurl = models.CharField(max_length=500,null=True)
    explain= models.CharField(max_length=20,null=True)
    sort_id = models.IntegerField()
    starttime =models.IntegerField()
    deadline = models.CharField(max_length=10,null=True)
    target = models.IntegerField(null=True)
    link_url = models.CharField(max_length=500,null=True)
    inner_link = models.CharField(max_length=500,null=True)
    inner_link_params = models.IntegerField(null=True)
    addtime= models.IntegerField()
    cname=models.ForeignKey(to='Regin_gg',on_delete=models.CASCADE)
    platform = models.ForeignKey(to="PlatfromModels",on_delete=models.CASCADE)
    name_img = models.CharField(max_length=100)
    # photo = models.ImageField(upload_to='photos',default='avatar.jpg')

# 图片不该就在这个表里面吗
# 存放图片的表
class Avatar(models.Model):
    user = models.CharField(max_length=100)
    photo = models.ImageField(upload_to='photos', default='avatar.jpg')


